package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DbShoppingCartMapper;
import com.ruoyi.system.domain.DbShoppingCart;
import com.ruoyi.system.service.IDbShoppingCartService;

/**
 * 购物车Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-03-22
 */
@Service
public class DbShoppingCartServiceImpl implements IDbShoppingCartService 
{
    @Autowired
    private DbShoppingCartMapper dbShoppingCartMapper;

    /**
     * 查询购物车
     * 
     * @param id 购物车主键
     * @return 购物车
     */
    @Override
    public DbShoppingCart selectDbShoppingCartById(Long id)
    {
        return dbShoppingCartMapper.selectDbShoppingCartById(id);
    }

    /**
     * 查询购物车列表
     * 
     * @param dbShoppingCart 购物车
     * @return 购物车
     */
    @Override
    public List<DbShoppingCart> selectDbShoppingCartList(DbShoppingCart dbShoppingCart)
    {
        return dbShoppingCartMapper.selectDbShoppingCartList(dbShoppingCart);
    }

    /**
     * 新增购物车
     * 
     * @param dbShoppingCart 购物车
     * @return 结果
     */
    @Override
    public int insertDbShoppingCart(DbShoppingCart dbShoppingCart)
    {
        dbShoppingCart.setCreateTime(DateUtils.getNowDate());
        return dbShoppingCartMapper.insertDbShoppingCart(dbShoppingCart);
    }

    /**
     * 修改购物车
     * 
     * @param dbShoppingCart 购物车
     * @return 结果
     */
    @Override
    public int updateDbShoppingCart(DbShoppingCart dbShoppingCart)
    {
        dbShoppingCart.setUpdateTime(DateUtils.getNowDate());
        return dbShoppingCartMapper.updateDbShoppingCart(dbShoppingCart);
    }

    /**
     * 批量删除购物车
     * 
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteDbShoppingCartByIds(Long[] ids)
    {
        return dbShoppingCartMapper.deleteDbShoppingCartByIds(ids);
    }

    /**
     * 删除购物车信息
     * 
     * @param id 购物车主键
     * @return 结果
     */
    @Override
    public int deleteDbShoppingCartById(Long id)
    {
        return dbShoppingCartMapper.deleteDbShoppingCartById(id);
    }
}
